/* eslint-disable no-empty */
<!--s
 * @Description: 个体配种管理
-->
<template>
  <BaseMainSlot>
    <template v-slot:zhactbar>
      <ActionBar
        :add-active="addActive"
        :del-active="delActive"
        :edit-active="editActive"
        :cancel-active="cancelActive"
        :save-active="saveActive"
        :has-save="false"
        @add="add"
        @cancel="cancel"
        @edit="edit"
        @del="del"
        @save="save"
      />
    </template>
    <template v-slot:searchbox>
      <div class="label-input mr-20">
        <div class="label">个体名称:</div>
        <div class="input">
          <el-select
            v-model="condition.name"
            clearable
            filterable
            placeholder="请选择"
          >
            <el-option
              v-for="(item, index) in bionIdList"
              :key="index + 'bionId'"
              :label="item.name"
              :value="item.name"
            />
          </el-select>
        </div>
      </div>
      <div class="label-input mr-20">
        <div class="label">耳标:</div>
        <div class="input">
          <el-input
            v-model="condition.eagTag"
            clearable
            placeholder="请输入耳标"
          />
        </div>
      </div>
      <div class="label-input mr-20">
        <div class="label">合养时间段:</div>
        <div class="input">
          <el-date-picker
            v-model="condition.startDate"
            align="right"
            type="date"
            placeholder="选择开始日期"
            value-format="timestamp"
          />
        </div>
      </div>
      <div class="label-input mr-20">
        <div class="input">
          <el-date-picker
            v-model="condition.endDate"
            align="right"
            type="date"
            placeholder="选择结束日期"
            value-format="timestamp"
          />
        </div>
      </div>
      <div class="search ml-20" @click="postQueryPageByCondition">
        <img src="~@/assets/action-bar-icon/search.png" />
      </div>
    </template>
    <template v-slot:content>
      <!-- :data="lists" -->
      <el-table
        ref="tableDataRef"
        :data="tableData"
        style="width: 100%"
        max-height="80%"
        border
        stripe
        highlight-current-row
        @current-change="handleCurrentChange"
        @selection-change="handleSelect"
      >
        <el-table-column type="selection" width="55" />
        <el-table-column type="index" label="序号" width="80" />
        <el-table-column prop="number" label="生育编号" />
        <el-table-column label="公羊信息">
          <template slot-scope="scope">
            <div v-if="scope.row.maleNameList">
              <span
                v-for="(item, index) in scope.row.maleNameList"
                :key="index + 'rom'"
              >
                <span
                  class="title name color"
                  @click.stop="checkMaleInfo(item.bionId)"
                >
                  {{ item ? item.name : "" }}
                </span>
              </span>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="母羊信息">
          <template slot-scope="scope">
            <div>
              <span
                v-for="(item, index) in scope.row.femaleNameList"
                :key="index"
              >
                <span
                  class="title color"
                  @click.stop="checkFemaleInfo(item.bionId)"
                >
                  {{ item ? item.name : "" }}
                </span>
              </span>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="totalFacilityName" label="合养设施" />
        <el-table-column label="合养持续时间">
          <template slot-scope="scope">
            <span>{{
              scope.row.startDate && scope.row.endDate
                ? `${formatDateTime(scope.row.startDate)}-${formatDateTime(
                  scope.row.endDate
                )}`
                : "没有记录!!!"
            }}</span>
          </template>
        </el-table-column>
        <el-table-column label="试情记录" width="150">
          <template slot-scope="scope">
            <span class="color" @click="checkTryLove(scope.row)">查看详情</span>
          </template>
        </el-table-column>
      </el-table>
      <Pagination
        :page-size="pageSize"
        :current-page="currentPage"
        :total-size="length"
        @changePageSize="changePageSize"
        @changeCurrentPage="changeCurrentPage"
      />
      <!-- 公羊详细信息 -->
      <el-dialog title="公羊详细信息" :visible.sync="maleDetailDialog">
        <el-form :model="maleDetail" label-position="left" label-width="100px">
          <el-row>
            <el-col :span="12">
              <el-form-item label="公羊来源:">
                <el-input v-model="maleDetail.type" disabled />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="关联批次:">
                <el-input v-model="maleDetail.batchNo" disabled />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="公羊名称:">
                <el-input v-model="maleDetail.name" disabled />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="公羊编号:">
                <el-input v-model="maleDetail.number" disabled />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="被毛类型:">
                <el-input v-model="maleDetail.clothingHair" disabled />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="养殖设施:">
                <el-input v-model="maleDetail.facilityFullName" disabled />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="年龄:">
                <el-input v-model="maleDetail.age" disabled />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="体重（斤）:">
                <el-input v-model="maleDetail.weight" type="number" placeholder="请输入体重" disabled />
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </el-dialog>
      <!-- 母羊详细信息 -->
      <el-dialog title="查看母羊信息" :visible.sync="femaleDetailDialog">
        <el-form
          :model="femaleDetail"
          label-position="left"
          label-width="100px"
        >
          <el-row>
            <el-col :span="12">
              <el-form-item label="母羊来源:">
                <el-input v-model="femaleDetail.type" disabled />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="母羊品种:">
                <el-input v-model="femaleDetail.plantVarietyName" disabled />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="被毛类型:">
                <el-input v-model="femaleDetail.clothingHair" disabled />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="年龄:">
                <el-input v-model="femaleDetail.age" disabled />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="体重（斤）:">
                <el-input v-model="femaleDetail.weight" type="number" placeholder="请输入体重" disabled />
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </el-dialog>
      <!-- 添加交配信息 -->
      <el-dialog title="交配信息管理" :visible.sync="addDialog">
        <el-form
          ref="addForm"
          :model="formDataF"
          label-position="right"
          label-width="100px"
        >
          <!-- 内部公羊 -->
          <el-row
            v-for="(item, indexs) in formDataF.maleIdList"
            :key="indexs + 'male'"
          >
            <el-col :span="12">
              <el-form-item
                :label="`内部公羊(${indexs + 1})` + ':'"
                :prop="'maleIdList[' + indexs + ']'"
                :rules="[
                  {
                    required: true,
                    message: '请选择',
                    trigger: ['blur', 'change'],
                  },
                ]"
              >
                <!-- <el-input v-model="formDataF.maleIdList[indexs]" clearable /> -->
                <el-select
                  v-model="formDataF.maleIdList[indexs]"
                  placeholder="请选择"
                  clearable
                  @change="changeSelect(breedMaleList, formDataF.maleIdList)"
                >
                  <el-option
                    v-for="(item1, index) in breedMaleList"
                    :key="index + 'breed'"
                    :label="item1.name"
                    :value="item1.bionId"
                    :disabled="item1.isShow"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-button
                v-show="indexs > 0"
                type="danger"
                icon="el-icon-delete"
                circle
                @click="delArr(breedMaleList, formDataF.maleIdList, indexs)"
              />
            </el-col>
          </el-row>
          <!-- 母羊来源 -->
          <el-row
            v-for="(item, indexs) in formDataF.femaleIdList"
            :key="indexs + 'males'"
          >
            <el-col :span="12">
              <el-form-item
                :label="`母羊(${indexs + 1})` + ':'"
                :prop="'femaleIdList[' + indexs + ']'"
                :rules="[
                  {
                    required: true,
                    message: '请选择',
                    trigger: ['blur', 'change'],
                  },
                ]"
              >
                <el-select
                  v-model="formDataF.femaleIdList[indexs]"
                  placeholder="请选择"
                  clearable
                  @change="
                    changeSelect(breedFemaleList, formDataF.femaleIdList)
                  "
                >
                  <el-option
                    v-for="(items, index) in breedFemaleList"
                    :key="index + 'breed'"
                    :label="items.name"
                    :value="items.bionId"
                    :disabled="items.isShow"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-button
                v-show="indexs > 0"
                type="danger"
                icon="el-icon-delete"
                circle
                @click="delArr(breedFemaleList, formDataF.femaleIdList, indexs)"
              />
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item
                label="开始时间:"
                placeholder="选择日期时间"
                prop="startDate"
                :rules="[
                  {
                    required: true,
                    message: '请选择开始时间',
                    trigger: ['blur', 'change'],
                  },
                ]"
              >
                <el-date-picker
                  v-model="formDataF.startDate"
                  placeholder="选择日期时间"
                  value-format="timestamp"
                  :picker-options="pickerOptionscreate"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="结束时间:"
                prop="endDate"
                placeholder="选择日期时间"
                :rules="[
                  {
                    required: true,
                    message: '请选择结束时间',
                    trigger: ['blur', 'change'],
                  },
                ]"
              >
                <el-date-picker
                  v-model="formDataF.endDate"
                  placeholder="选择日期时间"
                  value-format="timestamp"
                  :picker-options="pickerOptionsend"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item
                label="合养设施组"
                prop="facilityGroupId"
                :rules="[
                  {
                    required: true,
                    message: '请选择合养设施组',
                    trigger: ['blur', 'change']
                  },
                ]"
              >
                <el-select
                  v-model="formDataF.facilityGroupId"
                  placeholder="请选择合养设施组"
                  clearable
                  @change="newfacgetlist"
                >
                  <el-option
                    v-for="(item, index) in sszuArr"
                    :key="index + 'she'"
                    :label="item.groupName"
                    :value="item.facilityGroupId"
                  />
                </el-select>
              </el-form-item>
              <el-form-item
                label="合养设施:"
                prop="facility"
                :rules="[
                  {
                    required: true,
                    message: '请选择合养设施',
                    trigger: 'change'
                  },
                ]"
              >
                <el-select
                  v-model="formDataF.facility"
                  placeholder="请选择合养设施"
                  clearable
                >
                  <el-option
                    v-for="(item, index) in newfacilityList"
                    :key="index + 'she'"
                    :label="item.name"
                    :value="item.id"
                  />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <!-- 添加外部公羊 -->
        <el-dialog
          title="添加外部公羊"
          :visible.sync="externalMaleDialog"
          append-to-body
        >
          <el-form
            ref="addExternalMaleForm"
            :model="ExternalRamInfo"
            label-position="left"
            label-width="100px"
            :inline="true"
          >
            <el-row>
              <el-col :span="12">
                <el-form-item
                  label="公羊名称:"
                  prop="name"
                  :rules="[
                    {
                      required: true,
                      message: '请填写公羊名称',
                      trigger: ['blur', 'change'],
                    },
                  ]"
                >
                  <el-input v-model="ExternalRamInfo.name" clearable />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item
                  label="公羊编号:"
                  prop="number"
                  :rules="[
                    {
                      required: true,
                      message: '请填写公羊编号',
                      trigger: ['blur', 'change'],
                    },
                  ]"
                >
                  <el-input v-model="ExternalRamInfo.number" clearable />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item
                  label="合养设施:"
                  prop="facilityList"
                  :rules="[
                    {
                      required: true,
                      message: '请选择合养设施',
                      trigger: 'change',
                    },
                  ]"
                >
                  <el-select
                    v-model="ExternalRamInfo.facilityList"
                    placeholder="请选择"
                    clearable
                  >
                    <el-option
                      v-for="(item, index) in facilityList"
                      :key="index + 'sheID'"
                      :label="item.name"
                      :value="item.id"
                    />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item
                  label="被毛类型:"
                  prop="EnterClothingHair"
                  :rules="[
                    {
                      required: true,
                      message: '请选择被毛类型',
                      trigger: ['blur', 'change'],
                    },
                  ]"
                >
                  <el-select
                    v-model="ExternalRamInfo.EnterClothingHair"
                    placeholder="请选择"
                    clearable
                  >
                    <el-option
                      v-for="(item, index) in clothingHairList"
                      :key="index + 'clothingHair'"
                      :label="item.name"
                      :value="item.value"
                    />
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
          <span slot="footer" class="dialog-footer">
            <el-button class="model-cancel-btn" @click="externalMaleDialog = false">取 消</el-button>
            <el-button
              type="primary"
              class="model-submit-btn"
              @click="addExternalMale('addExternalMaleForm')"
            >确 定</el-button>
          </span>
        </el-dialog>
        <el-row>
          <el-col :span="6" />
          <el-col :span="6">
            <el-button
              type="primary"
              class="el-icon-circle-plus-outline"
              round
              @click="addMaleList"
            >添加内部公羊</el-button>
          </el-col>
          <el-col :span="6">
            <el-button
              type="primary"
              class="el-icon-circle-plus-outline"
              round
              @click="
                externalMaleDialog = true;
                ExternalRamInfo = {};
              "
            >添加外部公羊</el-button>
          </el-col>
          <el-col :span="6">
            <el-button
              type="primary"
              class="el-icon-circle-plus-outline"
              round
              @click="addFemaleList"
            >添加母羊</el-button>
          </el-col>
        </el-row>
        <span slot="footer" class="dialog-footer">
          <el-button class="model-cancel-btn" @click="addDialog = false">取 消</el-button>
          <el-button
            type="primary"
            class="model-submit-btn"
            @click="confirmAddMatingInformation"
          >确 定</el-button>
        </span>
      </el-dialog>

      <!-- 修改交配信息 -->
      <el-dialog title="修改交配信息" :visible.sync="updateMatingDialog">
        <el-form
          ref="updateMatingRef"
          :model="updateBreed"
          label-position="left"
          label-width="100px"
        >
          <el-row
            v-for="(item, indexs) in updateBreed.updataMaleIdList"
            :key="indexs + 'male'"
          >
            <el-col :span="12">
              <el-form-item
                :label="`公羊(${indexs + 1})` + ':'"
                :prop="'updataMaleIdList[' + indexs + ']'"
                :rules="[
                  {
                    required: true,
                    message: '请选择',
                    trigger: ['blur', 'change'],
                  },
                ]"
              >
                <el-select
                  v-model="updateBreed.updataMaleIdList[indexs]"
                  placeholder="请选择"
                  clearable
                  @change="
                    changeSelect(MaleIdListAll, updateBreed.updataMaleIdList)
                  "
                >
                  <el-option
                    v-for="(items, index) in MaleIdListAll"
                    :key="index + 'updateBreed'"
                    :label="items.name"
                    :value="items.bionId"
                    :disabled="items.isShow"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-button
                v-show="indexs > 0"
                type="danger"
                icon="el-icon-delete"
                circle
                @click="
                  delArr(MaleIdListAll, updateBreed.updataMaleIdList, indexs)
                "
              />
            </el-col>
            <el-col v-show="indexs === 0" :span="6">
              <el-button
                type="primary"
                class="el-icon-circle-plus-outline"
                round
                @click="updateBreed.updataMaleIdList.push('')"
              >添加公羊</el-button>
            </el-col>
          </el-row>
          <el-row
            v-for="(item, indexs) in updateBreed.updataFemaleIdList"
            :key="indexs + 'female'"
          >
            <el-col :span="12">
              <el-form-item
                :label="`母羊(${indexs + 1})` + ':'"
                :prop="'updataFemaleIdList[' + indexs + ']'"
                :rules="[
                  {
                    required: true,
                    message: '请选择',
                    trigger: ['blur', 'change'],
                  },
                ]"
              >
                <el-select
                  v-model="updateBreed.updataFemaleIdList[indexs]"
                  placeholder="请选择"
                  clearable
                  @change="
                    changeSelect(
                      breedFemaleList,
                      updateBreed.updataFemaleIdList
                    )
                  "
                >
                  <el-option
                    v-for="(items, index) in breedFemaleList"
                    :key="index + 'updateBreedfe'"
                    :label="items.name"
                    :value="items.bionId"
                    :disabled="items.isShow"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-button
                v-show="indexs > 0"
                type="danger"
                icon="el-icon-delete"
                circle
                @click="
                  delArr(
                    breedFemaleList,
                    updateBreed.updataFemaleIdList,
                    indexs
                  )
                "
              />
            </el-col>
            <el-col v-show="indexs === 0" :span="6">
              <el-button
                type="primary"
                class="el-icon-circle-plus-outline"
                round
                @click="updateBreed.updataFemaleIdList.push('')"
              >添加母羊</el-button>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="开始时间:">
                <el-date-picker
                  v-model="updateBreed.startDate"
                  type="datetime"
                  placeholder="选择日期时间"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="结束时间:">
                <el-date-picker
                  v-model="updateBreed.endDate"
                  type="datetime"
                  placeholder="选择日期时间"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="合养设施:">
                <el-select
                  v-model="updateBreed.updateBreedfacility"
                  placeholder="请选择"
                >
                  <el-option
                    v-for="(item, index) in facilityList"
                    :key="index + 'she'"
                    :label="item.name"
                    :value="item.id"
                  />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button class="model-cancel-btn" @click="updateMatingDialog = false">取 消</el-button>
          <el-button type="primary" class="model-submit-btn" @click="updateMating">确 定</el-button>
        </div>
      </el-dialog>

      <!-- 试情信息 -->
      <el-dialog title="试情管理" :visible.sync="dialogTableVisible">
        <el-button @click="addTryLove()">添加</el-button>
        <el-button
          type="danger"
          :disabled="tryActive"
          @click="delTryLove"
        >删除</el-button>
        <el-table
          ref="tableDataTryRef"
          class="TryTable"
          :data="tableDataTry"
          style="width: 100%"
          max-height="88%"
          border
          stripe
          highlight-current-row
          @selection-change="handleSelectTryLove"
        >
          <el-table-column type="selection" width="55" />
          <el-table-column type="index" label="序号" width="80" />
          <el-table-column label="试情母羊">
            <template slot-scope="scope">
              <div>
                <span
                  v-for="(item, index) in scope.row.tryLoveFemaleNameList"
                  :key="index"
                >
                  <span v-if="item" class="title">{{
                    item ? item.name : "-"
                  }}</span>
                </span>
              </div>
            </template>
          </el-table-column>
          <el-table-column label="怀孕母羊">
            <template slot-scope="scope">
              <div>
                <span
                  v-for="(item, index) in scope.row.pregnantFemaleNameList"
                  :key="index"
                >
                  <span v-if="item" class="title">{{
                    item ? item.name : "-"
                  }}</span>
                </span>
              </div>
            </template> </el-table-column><!-- totalFacilityName -->
          <!--facilityName  -->
          <el-table-column prop="facilityName" label="合养羊舍" />
          <el-table-column label="试情时间">
            <template slot-scope="scope">
              <span>{{
                scope.row.tryLoveDate
                  ? `${formatDateTime(scope.row.tryLoveDate)}`
                  : "没有记录!!!"
              }}</span>
            </template>
          </el-table-column>
          <el-table-column label="备注">
            <template slot-scope="scope">
              <span
                class="color"
                @click="checkRemark(scope.row)"
              >查看备注</span>
            </template>
          </el-table-column>
          <el-table-column label="修改">
            <template slot-scope="scope">
              <el-button
                type="primary"
                @click="updataTryLove(scope.row)"
              >修改</el-button>
            </template>
          </el-table-column>
        </el-table>
        <Pagination
          class="page"
          :page-size="pageSizeTry"
          :current-page="currentPageTry"
          :total-size="tryLength"
          @changePageSize="changePageSizeTry"
          @changeCurrentPage="changeCurrentPageTry"
        />
      </el-dialog>
      <!-- 添加试情信息 -->
      <el-dialog title="添加试情记录" :visible.sync="addTryLoveDialog">
        <el-form
          ref="addTeaserRef"
          :model="addTeaser"
          label-position="left"
          label-width="100px"
        >
          <el-row>
            <el-col :span="12">
              <el-form-item
                label="试情日期:"
                prop="tryLoveDate"
                :rules="[
                  {
                    reqsuired: true,
                    message: '请选择试情日期',
                    trigger: ['blur', 'change'],
                  },
                ]"
              >
                <el-date-picker
                  v-model="addTeaser.tryLoveDate"
                  placeholder="选择日期时间"
                  type="date"
                  value-format="yyyy-MM-dd"
                  clearable
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-form-item label="选择怀孕母羊:">
            <el-checkbox-group v-model="addTeaser.pregnantFemaleList">
              <el-checkbox
                v-for="(item, index) in tryLoveList"
                :key="index + 'add'"
                :label="item.result.bionId"
                border
              >{{ item.result.name }}</el-checkbox>
            </el-checkbox-group>
          </el-form-item>
          <el-row>
            <el-col :span="12">
              <el-form-item label="备注:">
                <el-input
                  v-model="addTeaser.remark"
                  type="textarea"
                  :autosize="{ minRows: 2, maxRows: 4 }"
                  placeholder="请输入内容"
                />
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button class="model-cancel-btn" @click="addDialog = false">取 消</el-button>
          <el-button type="primary" class="model-submit-btn" @click="ensure">确 定</el-button>
        </div>
      </el-dialog>
      <!-- 修改试情信息 -->
      <el-dialog title="修改试情记录" :visible.sync="updateDialog">
        <el-form
          ref="updateTeaserRef"
          :model="updateTeaser"
          label-position="left"
          label-width="100px"
        >
          <el-row>
            <el-col :span="12">
              <el-form-item
                label="试情日期:"
                prop="tryLoveDate"
                placeholder="选择日期时间"
                :rules="[
                  {
                    reqsuired: true,
                    message: '请选择开始时间',
                    trigger: ['blur', 'change'],
                  },
                ]"
              >
                <el-date-picker
                  v-model="updateTeaser.tryLoveDate"
                  placeholder="选择日期时间"
                  clearable
                  value-format="yyyy-MM-dd"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-form-item label="选择怀孕母羊:">
            <el-checkbox-group v-model="updateTeaser.pregnantFemaleList">
              <el-checkbox
                v-for="(item, index) in updateTeaser.showLoveList"
                :key="index + 'updata'"
                :label="item.bionId"
                border
              >{{ item.name }}</el-checkbox>
            </el-checkbox-group>
          </el-form-item>
          <el-row>
            <el-col :span="12">
              <el-form-item label="备注:">
                <el-input
                  v-model="updateTeaser.remark"
                  type="textarea"
                  :autosize="{ minRows: 2, maxRows: 4 }"
                  placeholder="请输入内容"
                />
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button class="model-cancel-btn" @click="updateDialog = false">取 消</el-button>
          <el-button type="primary" class="model-submit-btn" @click="updateEnsure">确 定</el-button>
        </div>
      </el-dialog>
      <!-- 查看试情备注 -->
      <el-dialog title="试情备注" :visible.sync="remarkDialog" width="30%">
        <span>{{ remark }}</span>
        <span slot="footer" class="dialog-footer">
          <el-button class="model-cancel-btn" @click="remarkDialog = false">取 消</el-button>
          <el-button
            type="primary"
            class="model-submit-btn"
            @click="remarkDialog = false"
          >确 定</el-button>
        </span>
      </el-dialog>
    </template>
  </BaseMainSlot>
</template>

<script>
import Pagination from "@/components/Pagination";
import ActionBar from "@/components/ActionBar/index";
import BaseMainSlot from "@/components/BaseMainSlot/baseone.vue";
import req from "@/api/digital-production/breeding-management/individual-breeding-management/index";
import reqs from "@/api/digital-production/breeding-management/teaser-management/index";
import { mymixin } from "@/utils/mixin";
export default {
  name: "BreedingManagement",
  components: {
    Pagination,
    ActionBar,
    BaseMainSlot
  },
  mixins: [mymixin],

  data() {
    var that = this;
    return {
      // 添加修改时动态设施
      newfacilityList: [],
      /* 试情管理开始*/
      remarkDialog: false,
      remark: "",
      tryActive: true,
      delTryID: [],
      queryID: "",
      sszuArr: [],
      // 原始数据
      originalData: [],
      // 试情母羊列表
      tryLoveList: [],
      showLoveList: [],
      // 怀孕母羊列表
      pregnantEwe: [],
      showPregnantEwe: [],
      addTeaser: {
        tryLoveDate: "",
        pregnantFemaleList: [],
        remark: ""
      },
      updateTeaser: {
        tryLoveDate: "",
        raiseRecordId: "",
        showLoveList: [],
        pregnantFemaleList: [],
        remark: ""
      },
      updateDialog: false,
      addTryLoveDialog: false,
      raiseTryRecordId: "",
      tryLength: 0,
      pageSizeTry: 10,
      currentPageTry: 1,
      tableDataTry: [],
      TryLovefacilityName: "",
      dialogTableVisible: false,
      /* 试情管理结束*/
      pickerOptionscreate: {
        disabledDate(time) {
          // 开始时间的禁用
          return time.getTime() > new Date(that.formDataF.endDate).getTime();
        }
      },
      // 结束时间
      pickerOptionsend: {
        disabledDate(time) {
          // 结束时间的禁用
          return time.getTime() < new Date(that.formDataF.startDate).getTime();
        }
      },

      delAble: [],
      raiseRecordId: "",
      // 条件查询:
      queryName: "",
      queryNumber: "",
      bionIdList: [],
      condition: {
        breed: "HuSheep",
        endDate: "",
        name: "",
        startDate: "",
        eagTag: ""
      },
      // 新
      sourceList: [
        { name: "繁育", value: "BREED" },
        { name: "外部", value: "PURCHASE" }
      ],
      clothingHairList: [
        { name: "棉毛型", value: "LINTER" },
        { name: "沙毛型", value: "ROAN" },
        { name: "中间型", value: "MIDDLE" }
      ],
      addDialog: false,
      length: 0,
      tableData: [],
      maleDetailDialog: false,
      maleDetail: {
        source: "",
        batchNo: "",
        name: "",
        number: "",
        type: "",
        facilityName: "",
        age: "",
        weight: ""
      },
      femaleDetailDialog: false,
      femaleDetail: {
        source: "",
        batchNo: "",
        name: "",
        number: "",
        type: "",
        facilityName: "",
        age: "",
        weight: ""
      },
      maleIdList: [],
      femaleIdList: [""],
      facilityList: [],
      //
      breedMaleList: [],
      resultBreedMaleList: [],

      breedFemaleList: [],
      resultBreedFemaleList: [],

      externalMale: {},
      startDate: "",
      endDate: "",
      facility: "", // 内部设施id
      externalFacility: "",
      externalMaleDialog: false,

      //
      updateMatingDialog: false,
      updataMaleIdList: [{}],
      breedMaleListAll: [],
      MaleIdListAll: [],
      updataFemaleIdList: [{}],
      ExternalRamIdList: "",
      ExternalRamInfo: { name: "" },
      EnterClothingHair: "",
      formDataF: {
        maleIdList: [""],
        femaleIdList: [""],
        startDate: "",
        endDate: "",
        facility: "",
        facilityGroupId: ""
      },
      updateBreed: { updataMaleIdList: [], updataFemaleIdList: [] },
      rules: {
        ram: [
          {
            required: true, // 是否必填
            message: "请选择公羊",
            trigger: ["blur", "change"] // 何事件触发
          }
        ],
        region: [
          { required: true, message: "请选择羊", trigger: ["blur", "change"] }
        ]
      },
      getIdArr: []
    };
  },
  computed: {},
  watch: {
    recordID: {
      handler: function (newval) {
        if (newval.length === 1) {
          this.editActive = true;
          this.delActive = true;
          this.addActive = false;
        } else if (newval.length > 0) {
          this.editActive = false;
          this.delActive = true;
          this.addActive = false;
        } else {
          this.editActive = false;
          this.delActive = false;
          this.addActive = true;
        }
      },
      deep: true
    },
    nowChanceStau(newval) {
      if (newval === "add") {
        this.changeSelect(this.breedMaleList, this.formDataF.maleIdList);
        this.changeSelect(this.breedFemaleList, this.formDataF.femaleIdList);
        this.newfacilityList = []
        this.addDialog = true;
      } else if (newval === "edit") {
        this.editData();
        // eslint-disable-next-line no-empty
      } else if (newval === "cancel") {
      }
    },
    addDialog(newval, oldval) {
      if (!newval) {
        this.$refs.addForm.resetFields();
      } else {
        this.formDataF = {
          maleIdList: [""],
          femaleIdList: [""],
          startDate: "",
          endDate: "",
          facility: "",
          facilityGroupId: ""
        };
      }
    },
    updateMatingDialog(newval) {
      if (!newval) {
        this.nowChanceStau = "";
      }
    },
    externalMaleDialog(newval) {
      if (!newval) {
        this.$refs.addExternalMaleForm.resetFields();
      }
    },
    tableData() {
      this.nowChanceStau = "";
    }
  },
  created() {
    this.pagingQuery();
    this.getQueryList();
    // this.getQueryBionByMale();
    this.getQueryBionByMatrix();
    // this.getQueryBionByMaleAll();
    this.postDelAbleByIdList();
    this.queryBionAll();
    // 获取添加是的羊下拉数据
    this.getAddQuery();
    // 获取设施组
    this.getsszu()
  },
  methods: {
    // 获取设施组
    getsszu() {
      let params = {}
      req.sszu(params).then((res) => {
        console.log(res.data)
        this.sszuArr = res.data
      })
    },
    // 查看备注
    checkRemark(val) {
      this.remark = val.remark ? val.remark : "暂无备注";
      this.remarkDialog = true;
    },
    delTryLove() {
      reqs
        .postDelByIdList(this.delTryID)
        .then((res) => {
          if (res.code === 1) {
            this.$message.success("删除成功!!!");
            this.pagingTryLove();
          } else {
            this.$message.error("删除失败!!!");
          }
        })
        .catch((res) => {});
    },
    // 删除记录ID
    handleSelectTryLove() {
      let result = this.$refs.tableDataTryRef.selection;
      let resultId = [];
      result.forEach((item) => {
        resultId.push(item.tryLoveId);
      });
      this.delTryID = resultId;
      if (result.length > 0) {
        this.tryActive = false;
      } else {
        this.tryActive = true;
      }
    },
    updataTryLove(val) {
      this.tryLoveId = val.tryLoveId;
      let preId = [];
      let tryId = [];
      this.updateTeaser.showLoveList = val.tryLoveFemaleNameList;
      val.pregnantFemaleNameList.forEach((item) => {
        preId.push(item.bionId);
      });
      val.tryLoveFemaleNameList.forEach((item) => {
        tryId.push(item.bionId);
      });
      this.updateTeaser.tryLoveDate = val.tryLoveDate;
      this.updateTeaser.pregnantFemaleList = preId;
      this.updateTeaser.raiseRecordId = val.raiseRecordId;
      this.updateTeaser.tryLoveId = val.tryLoveId;
      this.updateTeaser.tryLoveFemaleList = tryId;
      this.updateTeaser.remark = val.remark;
      this.updateDialog = true;
    },
    // 修改试情记录
    updateEnsure() {
      this.$refs["updateTeaserRef"].validate((valid) => {
        if (valid) {
          let tryId = "";
          tryId = this.updateTeaser.tryLoveId;
          let params = {
            organizationNo: sessionStorage.getItem("organizationNo"),
            pregnantFemaleList: this.updateTeaser.pregnantFemaleList,
            raiseRecordId: this.updateTeaser.raiseRecordId,
            tryLoveDate: this.updateTeaser.tryLoveDate,
            tryLoveFemaleList: this.updateTeaser.tryLoveFemaleList,
            remark: this.updateTeaser.remark,
            tryLoveId: tryId
          };
          reqs.postEdit(params).then((res) => {
            if (res.code === 1) {
              this.$message.success("修改成功!!!");
              this.pagingTryLove();
            } else {
              this.$message.error("修改失败!!!");
            }
          });
          this.getDate();
          this.updateDialog = false;
        } else {
          this.$message.error("请将信息填写完整!!!");
          return false;
        }
      });
    },
    // 获取初始化数据 试情母羊的列表
    async getDate() {
      await reqs.getQueryBionByMatrix(this.raiseTryRecordId).then((res) => {
        if (res.code === 1) {
          let result = [];
          res.data.forEach((item) => {
            result.push({
              result: item,
              isShow: false
            });
          });
          this.tryLoveList = result;
          this.originalData = JSON.parse(JSON.stringify(result));
          this.originalData.forEach((item) => {
            item.isShow = true;
          });
          this.showPregnantEwe = JSON.parse(JSON.stringify(this.originalData));
        }
      });
    },
    // 添加试情
    addTryLove() {
      this.getDate();
      this.addTryLoveDialog = true;
    },
    // 试情分页
    async pagingTryLove() {
      await reqs
        .postQueryPageByCondition(this.raiseTryRecordId, {
          page: this.currentPageTry,
          size: this.pageSizeTry
        })
        .then((res) => {
          if (res.code === 1) {
            let result = res.data || {};
            this.tryLength = result.totalElements;
            result = result.content || [];
            this.tableDataTry = result;
            this.tableDataTry.forEach((item) => {
              item.facilityName = this.TryLovefacilityName;
            });
            this.dialogTableVisible = true;
          }
        });
    },
    // 试情添加
    ensure() {
      this.$refs["addTeaserRef"].validate((valid) => {
        if (valid) {
          let tryId = [];
          this.tryLoveList.forEach((item) => {
            tryId.push(item.result.bionId);
          });
          var r = this.addTeaser.pregnantFemaleList.filter(function (item) {
            if (item !== "") return item;
          });
          let params = {
            organizationNo: sessionStorage.getItem("organizationNo"),
            // pregnantFemaleList: this.addTeaser.pregnantFemaleList,
            pregnantFemaleList: r,
            raiseRecordId: this.raiseTryRecordId,
            tryLoveDate: this.addTeaser.tryLoveDate,
            remark: this.addTeaser.remark,
            tryLoveFemaleList: tryId
          };
          if (params.pregnantFemaleList.length === 0) {
            this.$message.error("没有试情的羊");
          } else {
            reqs.postAdd(params).then((res) => {
              if (res.code === 1) {
                this.$message.success("添加成功");
                this.addTeaser = {
                  tryLoveDate: "",
                  pregnantFemaleList: [""],
                  tryLoveFemaleList: [""]
                };
                this.addTryLoveDialog = false;
                this.pagingTryLove();
              } else {
                this.$message.error(`${res.msg}!!!`);
              }
            });
          }
        } else {
          this.$message.error("请将信息填写完整!!!");
          return false;
        }
      });
    },
    // 查看试情页面
    checkTryLove(val) {
      this.raiseTryRecordId = "";
      if (Object.prototype.hasOwnProperty.call(val, "raiseRecordId")) {
        this.raiseTryRecordId = val.raiseRecordId;
        this.TryLovefacilityName = val.facilityName;
        reqs
          .postQueryPageByCondition(this.raiseTryRecordId, {
            page: this.currentPageTry,
            size: this.pageSizeTry
          })
          .then((res) => {
            if (res.code === 1) {
              let result = res.data || {};
              this.tryLength = result.totalElements;
              result = result.content || [];
              this.tableDataTry = result;
              this.tableDataTry.forEach((item) => {
                item.facilityName = val.facilityName;
              });
              this.dialogTableVisible = true;
            }
          });
      }
      this.getDate();
    },
    // 下拉数据，用户选择数据，删除元素的索引
    delArr(show, result, index) {
      result.splice(index, 1);
      this.changeSelect(show, result);
    },
    changeSelect(show, result) {
      show.forEach((items) => {
        items.isShow = false;
      });
      result.forEach((items, index) => {
        if (typeof items === "number") {
          show.forEach((item, index, arr) => {
            if (item.bionId === items) {
              item.isShow = true;
            }
          });
        }
      });
    },

    // 添加时可选的公禽集合
    getAddQuery() {
      // 获取添加时的公禽信息
      req.getQueryBionByAduitMale("HuSheep").then((res) => {
        if (res.code === 1) {
          this.breedMaleList = [];
          let result = res.data || [];
          result.forEach((item) => {
            this.breedMaleList.push({
              bionId: item.bionId,
              name: item.name,
              isShow: false
            });
          });
          this.resultBreedMaleList = JSON.parse(
            JSON.stringify(this.breedMaleList)
          );
        }
      });
      // 添加的母禽集合
      req.getQueryBionByAduitMatrix("HuSheep").then((res) => {
        if (res.code === 1) {
          this.breedFemaleList = [];
          let result = res.data || [];
          result.forEach((item) => {
            this.breedFemaleList.push({
              bionId: item.bionId,
              name: item.name,
              isShow: false
            });
          });
          this.resultBreedFemaleList = JSON.parse(
            JSON.stringify(this.breedFemaleList)
          );
        }
      });
    },
    // 修改时可选的禽类集合
    getupdata() {
      let params = {
        breed: "HuSheep",
        raiseRecordId: this.updateBreed.raiseRecordId
      };
      // 修改时可选的公禽集合
      req.getUpdataQueryAduitMale(params).then((res) => {
        if (res.code === 1) {
          this.MaleIdListAll = [];
          let result = res.data || [];
          result.forEach((item) => {
            this.MaleIdListAll.push({
              bionId: item.bionId,
              name: item.name,
              isShow: false
            });
          });
        }
      });
      // 修改时可选的母禽集合
      req.getUpdataQueryBionByAduitMatrix(params).then((res) => {
        if (res.code === 1) {
          this.breedFemaleList = [];
          let result = res.data || [];
          result.forEach((item) => {
            if (item) {
              this.breedFemaleList.push({
                bionId: item.bionId,
                name: item.name,
                isShow: false
              });
            }
          });
        }
      });
    },
    // 获取可以删除的ID
    postDelAbleByIdList() {
      req.postDelAbleByIdList().then((res) => {
        if (res.code === 1) {
          this.delAble = res.data || [];
        }
      });
    },
    // 条件查询
    postQueryPageByCondition() {
      req
        .postQueryPageByCondition({
          page: this.currentPage,
          size: this.pageSize,
          entity: this.condition
        })
        .then((res) => {
          if (res.code === 1) {
            res = res.data || {};
            this.length = res.totalElements;
            res = res.content || [];
            this.tableData = res;
          }
        });
    },
    queryBionAll() {
      req
        .queryBionAll({
          breed: "HuSheep"
        })
        .then((res) => {
          if (res.code === 1) {
            this.bionIdList = res.data || [];
          }
        });
    },
    // 获取分页数据
    pagingQuery() {
      req
        .postPageBreed({
          page: this.currentPage,
          size: this.pageSize,
          entity: this.condition
        })
        .then((res) => {
          if (res.code === 1) {
            res = res.data || {};
            this.length = res.totalElements;
            res = res.content || [];
            this.tableData = res;
          }
        });
    },

    // 修改交配信息
    editData() {
      this.updateMatingDialog = true;
    },
    // 添加外部公羊
    addExternalMale(val) {
      this.$refs[val].validate((valid) => {
        if (valid) {
          let params = {
            gender: "MALE",
            name: this.ExternalRamInfo.name,
            number: this.ExternalRamInfo.number,
            organizationNo: sessionStorage.getItem("organizationNo"),
            owner: false,
            clothingHair: this.ExternalRamInfo.EnterClothingHair,
            plantVarietyId: 5,
            source: "PURCHASE",
            stage: "ADULT",
            status: "SURVIVAL",
            type: "COMMON",
            facilityId: this.ExternalRamInfo.facilityList
          };
          req.postBionAdd(params).then((res) => {
            if (res.code === 1) {
              // this.maleIdList.push(res.data);
              let num = res.data
              this.getId(num)
              this.$message.success("添加成功");
              this.externalMaleDialog = false;
            } else {
              this.$message.error("添加失败");
            }
          });
          this.externalMaleDialog = false;
        } else {
          this.$message.error("请将信息填写完整!!!");
        }
      });
    },
    // 根据添加外部公羊的编号查找id
    // eslint-disable-next-line vue/no-dupe-keys
    getId(num) {
      // console.log(req)
      req.getID(num).then((res) => {
        // console.log(res.data.bionId)
        let arr = [res.data.bionId]
        this.getIdArr = arr
        console.log(this.getIdArr)
        // console.log(arr)
      })
      // console.log(111)
    },
    // 根据组织查询所有母本信息
    getQueryBionByMatrix() {
      req.getQueryBionByMatrix("HuSheep").then((res) => {
        if (res.code === 1) {
          let result = res.data || [];
          result.forEach((item) => {
            this.breedFemaleList.push({
              bionId: item.bionId,
              name: item.name
            });
          });
        }
      });
    },

    // 添加内部公羊配种
    addMaleList() {
      this.formDataF.maleIdList.push("");
    },
    addFemaleList() {
      this.formDataF.femaleIdList.push("");
    },
    // 根据个体ID查询详细信息
    getQeryBionById(params) {
      return req.getQeryBionById(params);
    },

    // 根据ID查看公羊信息
    checkMaleInfo(ID) {
      this.getQeryBionById(ID).then((res) => {
        if (res.code === 1) {
          let result = res.data || {};
          this.maleDetail = {
            type: result.type === "PURCHASE" ? "外部" : "繁育",
            batchNo: result.batchNo,
            name: result.name,
            number: result.number,
            facilityName: result.facilityName,
            age: result.age,
            weight: result.weight,
            totalFacilityName: result.facilityGroupName,
            facilityFullName: result.facilityFullName
            // FacilityName: (result.facilityGroupName ? result.facilityGroupName + "->" : "") + result.facilityName
          };
          this.clothingHairList.forEach((item) => {
            if (item.value === result.clothingHair) {
              this.maleDetail.clothingHair = item.name;
            }
          });
        }
      });

      this.maleDetailDialog = true;
    },
    // 查看母羊详细信息
    checkFemaleInfo(val) {
      this.getQeryBionById(val).then((res) => {
        if (res.code === 1) {
          let result = res.data || {};
          this.femaleDetail = {
            type: result.type === "PURCHASE" ? "外部" : "繁育",
            batchNo: result.batchNo,
            plantVarietyName: result.plantVarietyName,
            name: result.name,
            number: result.number,
            /* clothingHair: result.clothingHair, */
            facilityName: result.facilityName,
            age: result.age,
            weight: result.weight
          };
          this.clothingHairList.forEach((item) => {
            if (item.value === result.clothingHair) {
              this.femaleDetail.clothingHair = item.name;
            }
          });
        }
      });
      this.femaleDetailDialog = true;
    },

    // 添加配种信息
    confirmAddMatingInformation() {
      this.$forceUpdate();
      this.maleIdList = [];
      let result = "";
      this.$refs["addForm"].validate((valid) => {
        if (valid) {
          result = true;
        } else {
          result = false;
        }
      });
      if (result) {
        let ty = JSON.parse(JSON.stringify(this.formDataF));
        let params = {
          femaleIdList: ty.femaleIdList,
          maleIdList: ty.maleIdList.concat(this.maleIdList).concat(this.getIdArr),
          facilityId: ty.facility,
          facilityGroupId: ty.facilityGroupId,
          startDate: ty.startDate,
          endDate: ty.endDate,
          organizationNo: sessionStorage.getItem("organizationNo")
        };
        console.log(params)
        req.postAddBreed(params).then((res) => {
          if (res.code === 1) {
            this.$message.success("添加成功");
            this.addDialog = false;
            this.formDataF = {
              maleIdList: [""],
              femaleIdList: [""],
              startDate: "",
              endDate: "",
              facility: "",
              facilityGroupId: ""
            };
          } else {
            this.$message.error("添加失败");
            this.addDialog = false;
          }
          this.pagingQuery();
        });
        this.$refs.addForm.resetFields();
      }

      // this.addDialog = false;
    },
    // 添加或修改时设施筛选
    newfacgetlist(e) {
      this.newfacilityList = []
      this.formDataF.facility = ''
      let params = {
        // organizationNo: sessionStorage.getItem("organizationNo"),
        // facilityStatus: 1,
        facilityGroupId: e
      }
      req
        .getQueryList(params)
        .then((res) => {
          if (res.code === 1) {
            let result = res.data || [];
            result.forEach((item) => {
              this.newfacilityList.push({
                name: item.facilityName,
                id: item.facilityId
              });
            });
          }
        })
    },
    // 获取设施
    getQueryList(e) {
      let params = {
        organizationNo: sessionStorage.getItem("organizationNo"),
        facilityStatus: 1
      }
      req
        .getQueryList(params)
        .then((res) => {
          if (res.code === 1) {
            let result = res.data || [];
            result.forEach((item) => {
              this.facilityList.push({
                name: item.facilityName,
                id: item.facilityId
              });
            });
          }
        });
    },

    // 删除
    delmessage() {
      let lists = this.recordID;
      if (this.tableData.length <= lists.length && this.currentPage > 1) {
        this.currentPage -= 1;
      }
      req.postDelByIdList(lists).then((res) => {
        if (res.code === 1) {
          this.$message.success("删除成功");
        }
        this.pagingQuery();
      });
    },

    // 记录勾选的数据
    handleSelect(row) {
      if (row.length) {
        this.delActive = true;
        this.cancelActive = true;
      } else {
        this.delActive = false;
      }
      this.selectlist = this.$refs.tableDataRef.selection;
      // console.log(this.delAble)
      // 包含了可以删，没包含的不能删
      this.selectlist.forEach((ITEM) => {
        console.log(ITEM)
        let index = this.delAble.findIndex(item => item === ITEM.raiseRecordId)
        // console.log(index)
        if (index === -1) {
          this.$refs.tableDataRef.toggleRowSelection(ITEM);
          this.$message.success("该条记录不能删除");
        }
        // this.selectlist.forEach((item, index, arr) => {
        //   if (ITEM !== item.raiseRecordId) {
        //     this.$refs.tableDataRef.toggleRowSelection(item);
        //     this.$message.success("该条记录不能删除");
        //   }
        // });
      });
      let delID = []; // 收集记录ID
      let editDetail = []; // 收集记录详细
      this.selectlist.forEach((item) => {
        delID.push(item.raiseRecordId);
        editDetail.push(item);
      });
      this.recordID = delID;
      // return editDetail;
    },

    // 获取修改的信息
    async handleCurrentChange(val) {
      if (val) {
        let romId = [];
        let eweId = [];
        val.maleNameList.forEach((item) => {
          if (item) {
            romId.push(item.bionId);
          } else {
            romId.push("");
            return;
          }
        });
        val.femaleNameList.forEach((item) => {
          if (item) {
            eweId.push(item.bionId);
          } else {
            eweId.push("");
            return;
          }
        });
        this.updateBreed.updataMaleIdList = romId;
        this.updateBreed.updataFemaleIdList = eweId;
        // 不用set会导致日期无法修改
        this.$set(this.updateBreed, 'startDate', val.startDate)
        this.$set(this.updateBreed, 'endDate', val.endDate)
        this.updateBreed.updateBreedfacility = val.facilityId;
        this.updateBreed.raiseRecordId = val.raiseRecordId;
        this.editActive = true;
        this.cancelActive = true;
        let params = {
          breed: "HuSheep",
          raiseRecordId: this.updateBreed.raiseRecordId
        };
        // 修改时可选的公禽集合
        let p1 = req.getQueryBionByAduitMale(params.breed).then((res) => {
          if (res.code === 1) {
            this.MaleIdListAll = [];
            let result = res.data || [];
            result.forEach((item) => {
              this.MaleIdListAll.push({
                bionId: item.bionId,
                name: item.name,
                isShow: false
              });
            });
          }
        });
        // 修改时可选的母禽集合
        let p2 = req.getQueryBionByAduitMatrix(params.breed).then((res) => {
          if (res.code === 1) {
            this.breedFemaleList = [];
            let result = res.data || [];
            result.forEach((item) => {
              if (item) {
                this.breedFemaleList.push({
                  bionId: item.bionId,
                  name: item.name,
                  isShow: false
                });
              }
            });
          }
        });

        Promise.all([p1, p2]).then((res) => {
          this.changeSelect(
            this.MaleIdListAll,
            this.updateBreed.updataMaleIdList
          );
          this.changeSelect(
            this.breedFemaleList,
            this.updateBreed.updataFemaleIdList
          );
        });
      }
    },
    cancel() {
      this.$refs.tableDataRef.setCurrentRow();
      this.$refs.tableDataRef.clearSelection();
      this.addActive = true;
      this.cancelActive = false;
      this.editActive = false;
      this.nowChanceStau = "";
    },
    // 修改
    updateMating() {
      this.$refs["updateMatingRef"].validate((valid) => {
        if (valid) {
          let params = {
            raiseRecordId: this.updateBreed.raiseRecordId,
            femaleIdList: this.updateBreed.updataFemaleIdList,
            maleIdList: this.updateBreed.updataMaleIdList,
            facilityId: this.updateBreed.updateBreedfacility,
            startDate: this.updateBreed.startDate,
            endDate: this.updateBreed.endDate,
            organizationNo: sessionStorage.getItem("organizationNo")
          };
          req
            .postEdit(params)
            .then((res) => {
              if (res.code === 1) {
                this.$message.success("修改成功");
                this.pagingQuery();
              }
            })
            .catch((rej) => {
              this.$message.error(rej.msg);
            });
          this.updateMatingDialog = false;
        } else {
          this.$message.error("请将信息填写完整!!!");
        }
      });
    },
    // 分页功能实现
    changePageSize(pageSize) {
      this.pageSize = pageSize;
      this.pagingQuery();
    },
    changeCurrentPage(currentPage) {
      this.currentPage = currentPage;
      this.pagingQuery();
    },
    changePageSizeTry(pageSizeTry) {
      this.pageSizeTry = pageSizeTry;
      this.pagingTryLove();
    },
    changeCurrentPageTry(currentPageTry) {
      this.currentPageTry = currentPageTry;
      this.pagingTryLove();
    }
  }
};
</script>

<style scoped lang="scss">
// @import "~@/styles/variables.scss";
::v-deep .el-table {
  overflow: auto;
}
::v-deep .el-input__inner {
  background-color: transparent;
}
::v-deep .el-form-item__label {
  color: #fff;
}
::v-deep .el-dialog__header {
  background-color: #006e91;
}
::v-deep .el-dialog__body {
  background: #f0f3f7;
  color: #fff;
  max-height: 553px;
  overflow-y: scroll !important;
  .el-input {
    width: 100%;
  }
  .el-select {
    //充满父元素（el-col）
    width: 100%;
  }
}
.title {
  // border-bottom: 1px solid #0fd1d1;
  cursor: pointer;
  margin-left: 5px;
}

.search-box {
  width: 100%;
  height: 60px;
  margin-bottom: 10px;
  padding: 10px;
  background: #00485a;
  display: flex;
  align-items: center;
  .label-input {
    display: flex;
    align-items: center;
    .label {
      width: 100px;
      padding-right: 10px;
      text-align: end;
      white-space: nowrap;
    }
  }
  .search {
    display: flex;
    align-items: center;
    cursor: pointer;
    img {
      height: 30px;
    }
  }
}
.el-row {
  margin: 10px 0;
}
.el-col {
  min-height: 1px;
  text-align: center;
}
.teaseRecord {
  margin: 10px 0;
}
.title {
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
}
.TryTable {
  margin-top: 10px;
  margin-bottom: 70px;
  background-color: #00485a !important;
}
.page {
  position: absolute;
  right: 50px;
}
.color {
  cursor: pointer;
  color: #33bad4;
  border-bottom: 1px solid #33bad4;
}
// 弹框底下按钮样式
.model-submit-btn{
background-color: #006e91;
    border-color: #006e91;
    &:hover{
      background-color: #006f91b9;
    border-color: #006f91b9;
    }
}
.model-cancel-btn{
  &:hover{
      background-color: #006f9128;
    border-color: #006e91;
    color:#006e91
    }
}
</style>
